<template>
  <div>
    <van-search v-model="value" placeholder="请输入小区或地址" show-action>
      <template #label>
        <div @click="fn">上海▼</div>
      </template>
      <template #action>
        <van-icon name="location-o" size="20px" @click="$router.push('/map')" />
      </template>
    </van-search>
    <div>
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="item in list" :key="item.id">
          <img :src="'http://liufusong.top:8080' + item.imgSrc" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <van-grid class="biao">
      <van-grid-item icon="wap-home-o" text="整租" />
      <van-grid-item icon="friends-o" text="合租" />
      <van-grid-item icon="map-marked" text="地图找房" />
      <van-grid-item icon="wap-home-o" text="去出租" />
    </van-grid>
    <div class="box1">
      <div class="title">
        <h3>租房小组</h3>
        <span>更多</span>
      </div>
      <div class="pic">
        <van-grid :column-num="2" :gutter="7" direction="horizontal">
          <van-grid-item v-for="item in list1" :key="item.id">
            <img :src="'http://liufusong.top:8080' + item.imgSrc" alt="" />
            <p>
              {{ item.title }} <br />
              {{ item.desc }}
            </p>
          </van-grid-item>
        </van-grid>
      </div>
    </div>
  </div>
</template>

<script>
import { lunbo } from '@/api/lunbo'
import { zufang } from '@/api/zufang'
export default {
  async created() {
    const res = await lunbo()
    // console.log(res)
    this.list = res.body

    const res1 = await zufang('上海')
    // console.log(res1)
    this.list1 = res1.body
  },
  data() {
    return {
      value: '',
      list: [],
      list1: []
    }
  },
  methods: {
    fn() {
      this.$router.push('/citylist')
    }
  }
}
</script>

<style scoped lang="less">
.my-swipe .van-swipe-item {
  position: relative;
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #39a9ed;
  height: 211px;
}
.van-search {
  width: 360px;
  position: fixed;
  top: 15px;
  left: 50%;
  z-index: 100;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0);
}
.van-grid {
  height: 123px;
}
.box1 {
  background-color: #f6f5f6;
  height: 185px;
  padding: 15px 8px;
}
.box1 .title {
  margin-bottom: 30px;
  padding-left: 10px;
}
.box1 .title h3 {
  float: left;
  font-size: 15px;
  color: #333333;
}
.box1 .title span {
  float: right;
  color: #787d82;
  font-size: 14px;
}
.pic {
  height: 150px;
  // background-color: #fff;
  // background-color: red;
}
img {
  width: 100%;
}
.van-search__action {
  background-color: rgba(0, 0, 0, 0) !important;
}
.van-grid-item img {
  margin-left: -10px;
  width: 40px;
  height: 40px;
}
.van-grid-item p {
  margin-left: 10px;
  font-size: 14px;
}
.pic .van-grid-item {
  height: 60px;
}
</style>
